<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="format-detection" content="telephone=no">
    <meta name="HandheldFriendly" content="True">
    <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no">
	<style>
        body,div {margin: 0; padding: 0;}
        body{background: #fff;}
        #iphone {display: none; margin: 0 auto;}
        #android {display: none; margin: 0 auto;}
		#iphone img{width: 100%;}
		#android img{width: 100%;}
		#downloadPage{
			display: none;
			position: fixed;
			background: #dd2523;
			top: 0;
			bottom: 0;
			left: 0;
			right: 0;
			flex-direction: column;
			align-items: center;
			justify-content: center;
		}
		#downloadPage .img img{
			width: 100%;
		}
		#downloadPage .btn{
			display: flex;
			align-items: center;
			justify-content: center;
			flex-grow: 1;
			align-self: stretch;
		}
		#downloadPage .btn .downloadlnk{
			height: 50px;
			background: #FFF;
			border-radius: 50px;
			color: #dd2523;
			line-height: 50px;
			text-align: center;
			flex-grow: 1;
			margin: 0 15%;
		}
    </style>
    <title>下载丽华快餐APP</title>
</head>
<body>
<div id="iphone"><img src="/assets/img/appios.jpg" /></div>
<div id="android"><img src="/assets/img/appand.jpg" /></div>
<input id='android_downloadurl' type="hidden" value="{$download}">
<div id='downloadPage'>
	<div class="img"><img src="/assets/img/downloadimg.png?v=2" /></div>
	<div class="btn"><div class="downloadlnk" id="downloadlnk">手动下载丽华快餐APP</div></div>
</div>
<script src="https://newapp.lihua.com/assets/libs/jquery/dist/jquery.min.js"></script>
<script>
	var android_scheme_url = "lihuaapp://";//
	var ios_appstore_url = "https://apps.apple.com/cn/app/%E4%B8%BD%E5%8D%8E%E5%BF%AB%E9%A4%90/id628351424";//
	var android_downloadurl = "";//
	$(function(){
		//判断当前所在的平台
		var ua = navigator.userAgent.toLowerCase();
		var iOS = ( ua.match(/(ipad|iphone|ipod)/g) ? true : false );
		var android = ( ua.match(/android/i) ? true : false );
		var wx = ( ua.match(/micromessenger/i) ? true : false );
		// android_downloadurl = $("#android_downloadurl").val();
		android_downloadurl = 'https://api.lihua.com/static/app/lihua_app_android.apk';
		// android_downloadurl = 'https://api.lihua.com/static/app/lihua_app_6.0.0.apk';

		//此时还是微信页面，可以直接提示用户在浏览器打开
		if (wx) {
			if (iOS) {
				document.getElementById('iphone').style.display = 'block';
			} else if (android) {
			    document.getElementById('android').style.display = 'block';
			}
		}else{
			/**
			 * 此时已在浏览器页面打开页面
			 * **/
			document.getElementById('downloadPage').style.display = 'flex';
			if (iOS) {
			    //之前已经尝试过Universal Links打开app失败了，此处不错尝试，直接打开appstore
				// window.location = ios_appstore_url;
			} else if (android) {
				//android需要尝试scheme方式打开app
				// openAndroidClient(android_scheme_url);
			}
		}
		$("#downloadlnk").click(function(){
			if (iOS) {
				window.location = ios_appstore_url;
			} else if (android) {
				window.location = android_downloadurl;
			}
		})
	})
	function openAndroidClient(url) {
	    window.location = android_downloadurl;
	}
</script>
</body>
</html>
